/*
package com.lkx;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

*/
/**
 * ClassName: CustomExceptionHandle
 * Function:  TODO
 * Date:      2019-10-31 14:58
 * author     likaixuan
 * version    V1.0
 *//*

@ControllerAdvice
public class CustomExceptionHandle {
    private static final Logger logger = LoggerFactory.getLogger(CustomExceptionHandle.class);

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public ResultEntity handle(Exception e) {
        // 由我抛出的异常，返回错误码以及错误信息
        // 使用实例：throw new CustomException(ResultEnum.USER_TOKEN_NULL);
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            e.printStackTrace(new PrintStream(baos));
            String exception = baos.toString();
            if(!exception.contains("com.yshu.support.exception.CustomException")){
                logger.info("请求出现异常：" + exception);
                logger.info("请求出现异常-异常定位：" + exception.split("at ")[1]);
            }
            logger.error("请求出现异常:{}",e);
        } catch (Exception ex) {}
        if (e instanceof CustomException) {
            CustomException classException = (CustomException) e;
            return ResultTemplate.error(classException.getCode(), classException.getMessage(), classException.getData());
        } else if (e instanceof HttpRequestMethodNotSupportedException) {
            return ResultTemplate.error(10003, "请求类型错误：" + e.getMessage());
        } else if (e instanceof MissingServletRequestParameterException) {
            return ResultTemplate.error(10004, "参数未传或丢失：" + e.getMessage());
        } else if (e instanceof MethodArgumentTypeMismatchException) {
            return ResultTemplate.error(10005, "参数类型错误：" + e.getMessage());
        } else { // 其他异常，使用日志进行记录
            return ResultTemplate.error(-1, "请求失败，请重试~");
        }
    }
}
*/
